/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "salary")
@NamedQueries({
    @NamedQuery(name = "Salary.findAll", query = "SELECT s FROM Salary s"),
    @NamedQuery(name = "Salary.findBySalaryId", query = "SELECT s FROM Salary s WHERE s.salaryId = :salaryId"),
    @NamedQuery(name = "Salary.findBySalaryNum", query = "SELECT s FROM Salary s WHERE s.salaryNum = :salaryNum"),
    @NamedQuery(name = "Salary.findBySalaryDate", query = "SELECT s FROM Salary s WHERE s.salaryDate = :salaryDate"),
    @NamedQuery(name = "Salary.findByBonus", query = "SELECT s FROM Salary s WHERE s.bonus = :bonus")})
public class Salary implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "salary_id")
    private Integer salaryId;
    @Basic(optional = false)
    @Column(name = "salary_num")
    private double salaryNum;
    @Basic(optional = false)
    @Column(name = "salary_date")
    @Temporal(TemporalType.DATE)
    private Date salaryDate;
    @Column(name = "bonus")
    private Double bonus;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User user;

    public Salary() {
    }

    public Salary(Integer salaryId) {
        this.salaryId = salaryId;
    }

    public Salary(Integer salaryId, double salaryNum, Date salaryDate) {
        this.salaryId = salaryId;
        this.salaryNum = salaryNum;
        this.salaryDate = salaryDate;
    }

    public Integer getSalaryId() {
        return salaryId;
    }

    public void setSalaryId(Integer salaryId) {
        this.salaryId = salaryId;
    }

    public double getSalaryNum() {
        return salaryNum;
    }

    public void setSalaryNum(double salaryNum) {
        this.salaryNum = salaryNum;
    }

    public Date getSalaryDate() {
        return salaryDate;
    }

    public void setSalaryDate(Date salaryDate) {
        this.salaryDate = salaryDate;
    }

    public Double getBonus() {
        return bonus;
    }

    public void setBonus(Double bonus) {
        this.bonus = bonus;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (salaryId != null ? salaryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Salary)) {
            return false;
        }
        Salary other = (Salary) object;
        if ((this.salaryId == null && other.salaryId != null) || (this.salaryId != null && !this.salaryId.equals(other.salaryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.Salary[salaryId=" + salaryId + "]";
    }

}
